/* typehints:start */
import { GameRoot } from "../../../root";
import { Goods } from "../../goods";
/* typehints:end */

import { attrDefine } from "../../../defines/attr_define";
import { GoodComponent } from "./component_interface";

/**
 * 储物空间物品相关钩子设置
 */
export class EquipStorageComponent extends GoodComponent{
  constructor(...params){
		super(...params)
  }

	onEquiped(){
		this.root.hud.parts.backpackPage.drawBasicData();
	}

	onUnEquip(){
		let weight = this.good.getAttr(attrDefine.inventoryWeight.key, 0) + this.good.getAttr(attrDefine.weight.key, 1);
		if(this.root.backdrop.getAllWeight() > this.root.mainPlayer.getWeightKg() - weight){
			return '卸下后背包空间不足，无法卸下，请清理背包空间（请注意该物品自身的重量）';
		}
		return true;
	}

	onUnEquiped(){
		this.root.hud.parts.backpackPage.drawBasicData();
	}
}